package flowchart.app;

import java.io.File;

import javax.swing.filechooser.FileFilter;
/**
 *
 * Filefilter for filechooser
 * filters viewable files in filechooser
 */
public class ExtFilter extends FileFilter {

/**
 * Is file correct type
 * @param f file
 * @return if file has correct extension
 */
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 && i < s.length() - 1) {
            ext = s.substring(i + 1).toLowerCase();
        }

        String extension = ext;
        if (extension != null) {
            if (extension.equals("wtf")) {
                return true;
            } else {
                return false;
            }
        }
        return false;



    }


    public String getDescription() {
        return ".wtf";
    }
}

